home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 2.iso / STUTTGART / FROMUTS / DDEPASCAL / DDE / !PC / h / drawmod < prev    next >
Text File  |  1992-04-30  |  20KB  |  478 lines

  1. (*
  2.  * Title:    drawmod.h
  3.  * Purpose:  C interface to the Draw module
  4.  *
  5.  *)
  6.  
  7.  
  8. (*
  9.  * This file provides an interface to the Draw module (not to be confused
  10.  * with the !Draw application). It defines a number of types used for
  11.  * PostScript-like operations (with enhancements). The enhancements consist
  12.  * mainly of choice of fill style (fill including/excluding boundary etc),
  13.  * extra winding numbers, differing "leading"/"trailing" line caps and
  14.  * triangular line caps. It calls the Draw SWIs.
  15.  *
  16.  *)
  17.  
  18. #ifndef __drawmod_h
  19. #define __drawmod_h
  20.  
  21. #ifndef __os_h
  22. #include "os.h"
  23. #endif
  24.  
  25. #ifndef __drawftypes_h
  26. #include "drawftypes.h"
  27. #endif
  28.  
  29. (************************** Definition of a path **************************)
  30.  
  31. const     path_term      = 0;   (* end of path                  *)
  32.           path_ptr       = 1;   (* pointer to path continuation *)
  33.           path_move_2    = 2;   (* move to (x,y) -- new subpath *)
  34.                                 (* affects winding numbers      *)
  35.           path_move_3    = 3;   (* move to (x,y) -- new subpath *)
  36.                                 (* winding numbers unaffected   *)
  37.                                 (* (used internally)            *)
  38.           path_closegap  = 4;   (* close current subpath with   *)
  39.                                 (* a gap                        *)
  40.           path_closeline = 5;   (* close current subpath with   *)
  41.                                 (* a line                       *)
  42.           path_bezier    = 6;   (* Bezier curve to (x3,y3) with *)
  43.                                 (* control points at (x1,y1)    *)
  44.                                 (* and (x2,y2)                  *)
  45.           path_gapto     = 7;   (* gap to (x,y), not starting   *)
  46.                                 (* new subpath (used internally)*)
  47.           path_lineto    = 8;   (* line to (x,y)                *)
  48.  
  49. type drawmod_path_tagtype = integer;
  50.  
  51. type drawmod_path_endstr_ptr = ^drawmod_path_endstr;
  52.      drawmod_path_endstr =            (* end of path element *)
  53.        record
  54.          tag : drawmod_path_tagtype;
  55.          bytes_free : integer
  56.        end;
  57.  
  58. type drawmod_path_ptrstr_ptr = ^drawmod_path_ptrstr;
  59.      drawmod_path_ptrstr =            (* continuation ptr element *)
  60.        record
  61.          tag : drawmod_path_tagtype;
  62.          ptr : pointer
  63.        end;
  64.  
  65. type drawmod_path_movestr_ptr = ^drawmod_path_movestr;
  66.      drawmod_path_movestr =           (* move2/move3 element *)
  67.        record
  68.          tag : drawmod_path_tagtype;
  69.          x, y : integer
  70.        end;
  71.  
  72. type drawmod_path_closegapstr_ptr = ^drawmod_path_closegapstr;
  73.      drawmod_path_closegapstr =       (* close with gap element *)
  74.        record
  75.          tag : drawmod_path_tagtype
  76.        end;
  77.  
  78. type drawmod_path_closelinestr_ptr = ^drawmod_path_closelinestr;
  79.      drawmod_path_closelinestr =      (* close with line element *)
  80.        record
  81.          tag : drawmod_path_tagtype
  82.        end;
  83.  
  84. type drawmod_path_bezierstr_ptr = ^drawmod_path_bezierstr;
  85.      drawmod_path_bezierstr =         (* Bezier curve element *)
  86.        record
  87.          tag : drawmod_path_tagtype;
  88.          x1, y1 : integer;            (* control point (x1,y1) *)
  89.          x2, y2 : integer;            (* control point (x2,y2) *)
  90.          x3, y3 : integer             (* end point (x3,y3)     *)
  91.        end;
  92.  
  93. type drawmod_path_gaptostr_ptr = ^drawmod_path_gaptostr;
  94.      drawmod_path_gaptostr =          (* gap to (x,y) element *)
  95.        record
  96.          tag : drawmod_path_tagtype;
  97.          x, y : integer
  98.        end;
  99.  
  100. type drawmod_path_linetostr_ptr = ^drawmod_path_linetostr;
  101.      drawmod_path_linetostr =         (* line to (x,y) element *)
  102.        record
  103.          tag : drawmod_path_tagtype;
  104.          x, y : integer
  105.        end;
  106.  
  107. type drawmod_pathelemptr_tag = 0..10;
  108.      drawmod_pathelemptr_ptr = ^drawmod_pathelemptr;
  109.      drawmod_pathelemptr =            (* pointer to a path element *)
  110.        record
  111.          case drawmod_pathelemptr_tag of
  112.            0 : (_end : drawmod_path_endstr_ptr);
  113.            1 : (ptr : drawmod_path_ptrstr_ptr);
  114.            2 : (move2 : drawmod_path_movestr_ptr);
  115.            3 : (move3 : drawmod_path_movestr_ptr);
  116.            4 : (closegap : drawmod_path_closegapstr_ptr);
  117.            5 : (closeline : drawmod_path_closelinestr_ptr);
  118.            6 : (bezier : drawmod_path_bezierstr_ptr);
  119.            7 : (gapto : drawmod_path_gaptostr_ptr);
  120.            8 : (lineto : drawmod_path_linetostr_ptr);
  121.            9 : (bytep : ^byte);
  122.           10 : (wordp : ^integer)
  123.        end;
  124.  
  125. (****************************** fill type **********************************)
  126.  
  127. const     fill_Default        = $00000000;   (* default fill style - "fill to
  128.                                               * halfway through boundary,
  129.                                               * non-zero winding rule"
  130.                                               * NOTE: if used this should not
  131.                                               * be ORed with any other types
  132.                                               *)
  133.           fill_WNonzero       = $00000000;   (* non-zero winding rule *)
  134.           fill_WNegative      = $00000001;   (* negative   "       "  *)
  135.           fill_WEvenodd       = $00000002;   (* even-odd   "       "  *)
  136.           fill_WPositive      = $00000003;   (* positve    "       "  *)
  137.  
  138.           fill_FNonbext       = $00000004;   (* plot non-boundary exterior
  139.                                               * pixels
  140.                                               *)
  141.           fill_FBext          = $00000008;   (* plot boundary exterior
  142.                                               * pixels
  143.                                               *)
  144.           fill_FNonbint       = $00000010;   (* plot boundary interior
  145.                                               * pixels
  146.                                               *)
  147.           fill_FBint          = $00000020;   (* plot non-boundary interior
  148.                                               * pixels
  149.                                               *)
  150.                 (**************************************
  151.                  **************** NOTE ****************
  152.                  * The following should only be used in 
  153.                  * drawmod_processpath.
  154.                  **************************************
  155.                  **************************************
  156.                  *)
  157.  
  158.           fill_PClose         = $08000000;   (* close open subpaths *)
  159.           fill_PFlatten       = $10000000;   (* flatten the path *)
  160.           fill_PThicken       = $20000000;   (* thicken the path *)
  161.           fill_PReflatten     = $40000000;   (* re-flatten the path *)
  162.  
  163.                                              (* NOTE: floating point not
  164.                                               * supported so no $80000000.
  165.                                               *)
  166.  
  167. type drawmod_filltype_ptr = ^drawmod_filltype;
  168.      drawmod_filltype = integer;
  169.  
  170. (************************** line cap and join specs ************************)
  171.  
  172. type drawmod_capjoinspec_ptr = ^drawmod_capjoinspec;
  173.      drawmod_capjoinspec =
  174.        record
  175.          join : byte;                (* join style *)
  176.          leadcap : byte;             (* leading cap style *)
  177.          trailcap : byte;            (* trailing cap style *)
  178.          reserved8 : byte;           (* must be zero *)
  179.          mitrelimit : integer;       (* limit for mitred joins *)
  180.          lead_tricap_w : short;      (* "width" of leading triangular
  181.                                       * caps
  182.                                       *)
  183.          lead_tricap_h : short;      (* "height of leading triangular
  184.                                       * caps
  185.                                       *)
  186.          trail_tricap_w : short;     (* "width" of trailing triangular
  187.                                       * caps
  188.                                       *)
  189.          trail_tricap_h : short      (* "height" of trailing 
  190.                                       * triangular caps
  191.                                       *)
  192.        end;
  193.  
  194. (***************************** dash patterns *******************************)
  195. (*
  196.  * NOTE: This is the "header" for a dash pattern. It should be followed
  197.  * immediately in memory by the dash pattern itself. Each element of the
  198.  * dash pattern is a distance.
  199.  *)
  200. type drawmod_dashhdr_ptr = ^drawmod_dashhdr;
  201.      drawmod_dashhdr =
  202.        record
  203.          dashstart : integer;   (* distance into dash pattern to start *)
  204.          dashcount : integer    (* number of elements in the dash pattern *)
  205.        end;
  206.  
  207. (***************************** Line attributes *****************************)
  208. (*
  209.  * A line can have the following attributes:
  210.  *            Flatness:  given in user coords (0 means default == 2 OS units)
  211.  *            Thickness: 0 means one pixel wide, with line caps/joins
  212.  *                       ignored
  213.  *            Cap and Join specification: deals with joins and leading/
  214.  *                                        trailing caps.
  215.  *                                        see #defines in the line and cap
  216.  *                                        spec section above for their 
  217.  *                                        permissible values.
  218.  *            Dash pattern:  A contiguous block of memory, consisting of
  219.  *                           a header followed by a number of dash pattern
  220.  *                           elements.
  221.  *
  222.  *)
  223. type drawmod_line_ptr = ^drawmod_line;
  224.      drawmod_line =
  225.        record
  226.          flatness : integer;
  227.          thickness : integer;
  228.          spec : drawmod_capjoinspec;
  229.          dash_pattern : drawmod_dashhdr_ptr
  230.        end;
  231.           
  232.  
  233. (*************************** transformation matrix *************************)
  234. (*
  235.  * The transformation matrix has six elements (say a,b,c,d,e,f), where 
  236.  * elements appear in the standard matrix thus:
  237.  *                ( a b 0 )
  238.  *                ( c d 0 )
  239.  *                ( e f 1 )
  240.  * a,b,c,d should be considered as having 16 binary places (ie. 0x10000 is
  241.  * given to represent 1.0); e and f represent a translation in output units
  242.  *
  243.  *) 
  244. type drawmod_transmat_ptr = ^drawmod_transmat;
  245.      drawmod_transmat = array[0..5] of integer;
  246.  
  247.  
  248. (******************************* path buffer *******************************)
  249. (*
  250.  * This data type is used both as an input path buffer and an output path
  251.  * buffer header. Typically, you should allocate enough space for your path
  252.  * and then set a variable of type drawmod_buffer* to point at it.
  253.  * NOTE that on passing to functions in this module which take a
  254.  * drawmod_buffer* parameter, field zeroword should contain 0,and
  255.  * sizeword should indicate how many bytes follow in memory.
  256.  *
  257.  *)
  258. type drawmod_buffer_ptr = ^drawmod_buffer;
  259.      drawmod_buffer =
  260.        record
  261.          zeroword : integer;
  262.          sizeword : integer
  263.        end;
  264.           
  265.  
  266. (**************************** options for process path *********************)
  267.  
  268. const       tag_fill = 1;
  269.             tag_box  = 2;
  270.             tag_buf  = 3;
  271.  
  272. type drawmod_tagtype = 1..3;
  273.  
  274.  
  275. const       option_insitu      = 0;  (* output path to input path *)
  276.             option_normalfill  = 1;  (* fill normally *)
  277.             option_subpathfill = 2;  (* fill subpath by subpath *)
  278.             option_countsize   = 3;  (* count size of required buffer *)
  279.  
  280. type drawmod_filling_options = integer;
  281.  
  282. type drawmod_box_ptr = ^drawmod_box;
  283.      drawmod_box =
  284.        record
  285.          lowX, lowY : integer;
  286.          highX, highY : integer
  287.        end;
  288.  
  289. type drawmod_options_ptr = ^drawmod_options;
  290.      drawmod_options =
  291.        record
  292.          case tag : drawmod_tagtype of
  293.            1 : (opts : drawmod_filling_options);
  294.            2 : (box : drawmod_box_ptr); (* pointer to word-aligned, four-word
  295.                                          * area to hold bounding box of
  296.                                          * processed path.
  297.                                          *)
  298.            3 : (buffer : drawmod_buffer_ptr)
  299.        end;
  300.            
  301.  
  302. (* ----------------------------- drawmod_fill ------------------------------
  303.  * Description:   Emulate Postscript "fill" operator - ie. close open 
  304.  *                subpaths, flatten the path, transform it to standard coords
  305.  *                and fill the result.
  306.  *
  307.  * Parameters:    drawmod_pathelemptr path_seq - sequence of path elements
  308.  *                drawmod_filltype fill_style - style of fill
  309.  *                drawmod_transmat *matrix - transformation matrix
  310.  *                                           (0 for the identity matrix)
  311.  *                int flatness - flatness in user coords (0 means default)
  312.  *
  313.  * Returns:       possible error condition
  314.  * Other Info:    none.
  315.  *
  316.  *)
  317. procedure drawmod_fill(path_seq : drawmod_pathelemptr;
  318.                 fill_style : drawmod_filltype;
  319.                 matrix : drawmod_transmat_ptr;
  320.                 flatness : integer) : error; extern;
  321.  
  322.  
  323. (* -------------------------- drawmod_stroke -------------------------------
  324.  * Description:   Emulate PostScript "stroke" operator.
  325.  *
  326.  * Parameters:    drawmod_pathelemptr path_seq - sequence of path elements
  327.  *                drawmod_filltype fill_style - style of fill
  328.  *                drawmod_transmat *matrix - transformation matrix
  329.  *                                           (0 means identity matrix)
  330.  *                drawmod_line *line_style - (see typedef above for details)
  331.  *
  332.  * Returns:       possible error condition.
  333.  * Other Info:    none.
  334.  *
  335.  *)
  336. procedure drawmod_stroke(path_seq : drawmod_pathelemptr;
  337.                 fill_style : drawmod_filltype;
  338.                 matrix : drawmod_transmat_ptr;
  339.                 line_style : drawmod_line_ptr) : error; extern;
  340.  
  341.  
  342. (* -------------------------- drawmod_do_strokepath ------------------------
  343.  * Description:   Puts path through all stages of drawmod_stroke except the
  344.  *                final fill. Resulting path is placed in the buffer.
  345.  *
  346.  * Parameters:    drawmod_pathelemptr path_seq - sequence of path elements
  347.  *                drawmod_transmat *matrix - transformation matrix
  348.  *                drawmod_line *line_style - (see typedef above for details)
  349.  *                drawmod_buffer *buffer - buffer to hold stroked path. 
  350.  * Returns:       possible error condition
  351.  * Other Info:    none.
  352.  *
  353.  *)
  354. procedure drawmod_do_strokepath(path_seq : drawmod_pathelemptr;
  355.                 matrix : drawmod_transmat_ptr;
  356.                 line_style : drawmod_line_ptr;
  357.                 buffer : drawmod_buffer_ptr) : error; extern;
  358.  
  359.  
  360. (* ------------------------ drawmod_ask_strokepath -------------------------
  361.  * Description:   Puts path through all stages of drawmod_stroke, except the
  362.  *                fill, and returns the size of buffer needed to hold such
  363.  *                a path.
  364.  *
  365.  * Parameters:    drawmod_pathelemptr path_seq - sequence of path elements
  366.  *                drawmod_transmat *matrix - transformation matrix
  367.  *                drawmod_line *line_style - (see typedef above for details)
  368.  *                int *buflen - returned length of required buffer.
  369.  * Returns:       possible error condition.
  370.  * Other Info:    none.
  371.  *
  372.  *)
  373. procedure drawmod_ask_strokepath(path_seq : drawmod_pathelemptr;
  374.                 matrix : drawmod_transmat_ptr;
  375.                 line_style : drawmod_line_ptr;
  376.                 var buflen : integer) : error; extern;
  377.  
  378.  
  379. (* -------------------------- drawmod_do_flattenpath -----------------------
  380.  * Description:   Flatten the given path, and put into the supplied buffer.
  381.  *
  382.  * Parameters:    drawmod_pathelemptr path_seq - sequence of path elements
  383.  *                drwamod_buffer *buffer - buffer to hold flattened path
  384.  *                int flatness - required flatness.
  385.  *
  386.  * Returns:       possible error condition.
  387.  * Other Info:    none.
  388.  *
  389.  *)
  390. procedure drawmod_do_flattenpath(path_seq : drawmod_pathelemptr;
  391.                 buffer : drawmod_buffer_ptr;
  392.                 flatness : integer) : error; extern;
  393.  
  394.  
  395. (* -------------------------- drawmod_ask_flattenpath ----------------------
  396.  * Description:   Put the given path through the stages of 
  397.  *                drawmod_flattenpath and return the size of buffer needed
  398.  *                to hold the resulting path.
  399.  *
  400.  * Parameters:    drawmod_pathelemptr path_seq - sequence of path elements
  401.  *                int flatness - required flatness.
  402.  *                int *buflen - returned length of required buffer.
  403.  * Returns:       possible error condition.
  404.  * Other Info:    none.
  405.  *
  406.  *)
  407. procedure drawmod_ask_flattenpath(path_seq : drawmod_pathelemptr;
  408.                 flatness : integer;
  409.                 var buflen : integer) : error; extern;
  410.  
  411.  
  412. (* -------------------------- drawmod_buf_transformpath --------------------
  413.  * Description:   Put a path through a transformation matrix, and put the
  414.  *                result in the supplied buffer.
  415.  *
  416.  * Parameters:    drawmod_pathelemptr path_seq - sequenec of path elements
  417.  *                drawmod_buffer *buffer - buffer to hold transformed path
  418.  *                drawmod_transmat *matrix - the transformation matrix.
  419.  * Returns:       possible error condition.
  420.  * Other Info:    none.
  421.  *
  422.  *)
  423. procedure drawmod_buf_transformpath(path_seq : drawmod_pathelemptr;
  424.                 buffer : drawmod_buffer_ptr;
  425.                 matrix : drawmod_transmat_ptr) : error; extern;
  426.                                                        
  427.  
  428. (* ----------------------- drawmod_insitu_transformpath --------------------
  429.  * Description:   Put a path through a transformation matrix, by modifying
  430.  *                the supplied path itself.
  431.  *
  432.  * Parameters:    drawmod_pathelemptr path_seq - sequence of path elements
  433.  *                drawmod_transmat *matrix - the transformation matrix.
  434.  * Returns:       possible error condition.
  435.  * Other Info:    none.
  436.  *
  437.  *)
  438. procedure drawmod_insitu_transformpath(path_seq : drawmod_pathelemptr;
  439.                 matrix : drawmod_transmat_ptr) : error; extern;
  440.  
  441.  
  442. (* -------------------------- drawmod_processpath --------------------------
  443.  * Description:   Put the path through a set of processes used when doing
  444.  *                Stroke and Fill.
  445.  *
  446.  * Parameters:    drawmod_pathelemptr path_seq - sequence of path elements
  447.  *                drawmod_filltype fill_style - style of fill
  448.  *                drawmod_transmat *matrix - the transformation matrix
  449.  *                drawmod_line *line_style - (see typedef above for details)
  450.  *                drawmod_options *options - this can have the values
  451.  *                                           detailed below. Note: pass in 
  452.  *                                           address of a draw_options struct
  453.  *                int *buflen - returned length of required buffer
  454.  *                              (only used when options->tagtype==tag_fill
  455.  *                               && options->data.opts == option_countsize).  * Returns:       possible error condition.
  456.  * Other Info:    Possible values for options:
  457.  *                     drawmod_insitu: output to the input path
  458.  *                                     (only if path size wouldn't change)
  459.  *                     drawmod_fillnormal : fill path normally
  460.  *                     drawmod_fillsubpath : fill path, subpath by subpath
  461.  *                  OR an address : output bounding box of path to the
  462.  *                                  word-aligned address, and three next
  463.  *                                  words, with word-order lowX, lowY, 
  464.  *                                  highX, highY
  465.  *                  OR a buffer to hold processed path.
  466.  *
  467.  *)
  468. procedure drawmod_processpath(path_seq : drawmod_pathelemptr;
  469.                 fill_style : drawmod_filltype;
  470.                 matrix : drawmod_transmat_ptr;
  471.                 line_style : drawmod_line_ptr;
  472.                 options : drawmod_options_ptr;
  473.                 var buflen : integer) : error; extern;
  474.  
  475. #endif
  476.  
  477. (* end drawmod.h *)
  478.